﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ProductStore.Models;

namespace ProductStore.Controllers
{
    public class ProductController : Controller
    {
        IEntityRepository<Product> productRepository;

        public ProductController() : this(new EntityRepository<Product>()) { }

        public ProductController(IEntityRepository<Product> repository) {
            productRepository = repository;
        }

        //
        // GET: /Product/

        public ActionResult Index()
        {
            var context = new UsersContext();
            var username = User.Identity.Name;
            var user = context.UserProfiles.SingleOrDefault(u => u.UserName == username);
            var email = user.Email;

            var products = productRepository.GetAll();
            return View(products);
        }

    }
}
